package ljl.alg.wangzheng_camp.round1.tree;

import commons.TreeNode;

public class _617_merge_tree {
    
    /**
     * 这种题不要用迭代吧，太傻比了
     * 代码比这个长十倍多
     * */
    TreeNode mergeTrees(TreeNode left, TreeNode right) {
        if (left == null) return right;
        if (right == null) return left;
        left.val += right.val;
        left.left = mergeTrees(left.left, right.left);
        left.right = mergeTrees(left.right, right.right);
        return left;
    }
}
